unit ASetMenuDataSet;

interface

uses
  cxCheckBox, AData,

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, AModelBrowser, cxTL,
  cxMaskEdit, dxSkinsCore, dxSkinsDefaultPainters, StdCtrls, DBCtrls,
  cxGroupBox, cxCheckGroup, cxContainer, cxEdit, cxSplitter, ExtCtrls,
  cxInplaceContainer, cxDBTL, cxControls, cxTLData, DB, MemDS, DBAccess,
  MyAccess, Menus, ActnList, frxClass, frxDesgn, ComCtrls, ToolWin, Grids,
  Wwdbigrd, Wwdbgrid, cxTextEdit, cxDBEdit, cxGraphics, cxCustomData,
  cxStyles;

type
  TSetMenuDataSetForm = class(TAModelBrowserFrame)
    DMenuTree: TMyDataSource;
    QMenuTree: TMyQuery;
    QMenuTreemenu_name: TStringField;
    QMenuTreemenu_desc: TStringField;
    QMenuTreeparent_name: TStringField;
    cxDBTreeList1: TcxDBTreeList;
    cxDBTreeList1menu_name: TcxDBTreeListColumn;
    cxDBTreeList1menu_desc: TcxDBTreeListColumn;
    cxDBTreeList1parent_name: TcxDBTreeListColumn;
    Panel1: TPanel;
    cxSplitter2: TcxSplitter;
    cxGroupBox1: TcxGroupBox;
    checkBoxList: TcxCheckGroup;
    cxSplitter1: TcxSplitter;
    wwDBGrid1: TwwDBGrid;
    Qsys_datasets: TMyQuery;
    Dsys_datasets: TMyDataSource;
    Qsys_datasetsmenu_name: TStringField;
    Qsys_datasetsdataset_name: TStringField;
    Qsys_datasetsdataset_window: TStringField;
    Qsys_datasetsdataset_limit: TIntegerField;
    Qsys_datasetsdataset_remark: TStringField;
    Qsys_datasetscreate_name: TStringField;
    Qsys_datasetscreate_date: TDateTimeField;
    Qsys_datasetsupd_name: TStringField;
    Qsys_datasetsupd_date: TDateTimeField;
    menu_name: TLabel;
    dataset_name: TLabel;
    dataset_window: TLabel;
    dataset_limit: TLabel;
    dataset_remark: TLabel;
    create_name: TLabel;
    create_date: TLabel;
    upd_name: TLabel;
    upd_date: TLabel;
    cxDBedtmenu_name: TcxDBTextEdit;
    cxDBedtdataset_name: TcxDBTextEdit;
    cxDBedtdataset_window: TcxDBTextEdit;
    cxDBedtdataset_limit: TcxDBTextEdit;
    cxDBedtdataset_remark: TcxDBTextEdit;
    cxDBedtcreate_name: TcxDBTextEdit;
    cxDBEdtcreate_date: TcxDBTextEdit;
    cxDBedtupd_name: TcxDBTextEdit;
    cxDBedtupd_date: TcxDBTextEdit;
    procedure ActionSaveExecute(Sender: TObject);
    procedure Qsys_datasetsAfterScroll(DataSet: TDataSet);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  SetMenuDataSetForm: TSetMenuDataSetForm;

implementation

{$R *.dfm}

procedure TSetMenuDataSetForm.ActionSaveExecute(Sender: TObject);
var i: Integer;
    LimitValue: Integer;
begin
  LimitValue := 0;
  for i := 0 to checkBoxList.Properties.Items.Count -1 do
  begin
    if checkBoxList.States[i] = (cbsChecked) then
      LimitValue := LimitValue + checkBoxList.Properties.Items[i].Tag;
  end;
  if Qsys_datasetsdataset_limit.Value <> LimitValue then
  Qsys_datasetsdataset_limit.Value := LimitValue;
  inherited;

  ADMSystem.Qsys_datasets.Refresh;

end;

procedure TSetMenuDataSetForm.Qsys_datasetsAfterScroll(DataSet: TDataSet);
var limitValue: Integer;
    i: integer;
begin
  inherited;
  limitValue :=  Qsys_datasetsdataset_limit.Value;
  for i := 0 to checkBoxList.Properties.Items.Count -1 do
  begin
    if checkBoxList.Properties.Items[i].Tag = (limitValue and checkBoxList.Properties.Items[i].Tag) then
      checkBoxList.States[i] := cbsChecked else checkBoxList.States[i] := cbsUnchecked;
  end;
  
end;

initialization
  RegisterClass(TSetMenuDataSetForm);
finalization
  UnRegisterClass(TSetMenuDataSetForm);

end.
